// JavaScript Document

$(document).ready(function(){
	var $win = $(window);
	if ($("#Scroller-Left").is(':visible')) {
		var showScroll = function(){
			var o = document.getElementById("content");
			var h = o.offsetHeight;
			scroller  = new jsScroller(document.getElementById("Scroller-Left"), 217,h);
			scrollbar = new jsScrollbar (document.getElementById("Scrollbar-ContainerLeft"), scroller, true);
		}
		showScroll();
	}
	$win.resize(function () { if ($("#Scroller-Left").is(':visible')) { showScroll(); } });
	$(".selectul").each(function(index, $this){
		var Index = 9;
		$(this).css({"z-index":Index-index})
	});
	//
	if ($(".tabmenu .icon,.com_table .icon").is(':visible')){
		$('.tabmenu .icon,.com_table .icon').simpletooltip({
			color: '#fff',
			border_width:0,
			background_color:'#e55c25',
			position: 'bottom'
		});
	}
	var $boxheight = $("#content").height();
	
	$(".main_left").append("<div class='left_arrow'>&lt;</div>");
	$(".left_arrow").click(function(){
		if($(this).text()=="<"){
			$(this).text(">")
			$(".main_left").animate({"margin-left":"-217px"});
			$("#main_right").animate({"margin-left":"0"});
		}else{
			$(this).text("<")
			$(".main_left").animate({"margin-left":"0"});
			$("#main_right").animate({"margin-left":"217px"});
		}
	})
	$(".menu>ul>li>a").click(function(){
		//收缩全部展开的菜单
		$(".menu>ul>li>ul:visible").slideUp();
		//去掉菜单选中样式
		$(".menu>ul>li").removeClass("curr");
		
		var $Li = $(this).parent("li");
		//$Li.toggleClass("curr");//当菜单点击过于快速时选中效果会错乱,update by shuliangxing	
		var $con = $(this).parent("li").children("ul");
		
		if($con.is(":hidden")){
			$Li.addClass("curr");
			$con.slideDown();
		}else{
			$Li.removeClass("curr");
			$con.slideUp();
		}
	})
	//
	$(".child a").click(function(e){
		e.preventDefault();
		var Pare = $(this).parent(".child").parent(".row").next(".son");
		if(Pare.is(":hidden")){
			$(this).addClass("curr");
			Pare.show();
		}else if(Pare.is(":visible")){
			$(this).removeClass("curr");
			Pare.hide();
			return false;
		}
	});
	$('input:text').each(function(){  
		var txt = $(this).val();  
		$(this).focus(function(){  
			if(txt === $(this).val())
			{
				$(this).val("");  
				$(this).css({"color":"#333"})
			}
			}).blur(function(){if($(this).val() == "")
			{
				$(this).val(txt); 
				$(this).css({"color":"#999"})
			}
		});  
	})  

});